package com.zhq.util;

import java.text.DateFormat;
import java.text.Format;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author:钟豪强
 * @Description:    时间转换工具
 * @Date Created in  2020-08-13 21:20
 * @Modified By:
 */
public class DateFormatUtil {

    private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String format(Date date){
        return format.format(date);
    }

    public static long toTime(String formatString){
        try {
          return  format.parse(formatString).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
